package string;

public class Test {
    public static void main(String[] args) {
        String str1="www.tedu.cn";
        String str2="https://www.tarena.com.cn";
        String name1=getHostName(str1);
        String name2=getHostName(str2);
        System.out.println(name1);
        System.out.println(name2);

        String s = "  ";
        System.out.println("去除后"+s.trim()+".");
    }
    public static String getHostName(String url){
        int indexFirst=url.indexOf(".")+1;
        int indexSecond=url.indexOf(".",indexFirst);
        String hostName=url.substring(indexFirst,indexSecond);
        return hostName;
    }
}
